$numOfSeries = 50;
$lengthOfSeries = 100;
$occupiedRatio = 0.5;

$noise = int(rand(8))-100;  #noise floor is [-92,-100].
@sample;
for($i=0;$i<$lengthOfSeries;$i++){
	for($j=0;$j<$numOfSeries;$j++){
		$sample[$j][$i]=0;
	}
}
$i = 0;
for($i=0;$i<$numOfSeries;$i++){
	$occupiedRatio = int(rand(10));
	$fileName="randomSeries$numOfSeries.log";
	$occupiedRatio /= 10;
	
	print "$occupiedRatio\n";
	#open fout, ">.\\randomDistance\\$fileName" or die "can not open file .\\randomDistance\\$fileName\n";
	$j=0;
	for(;$j<$lengthOfSeries;$j++) {
		$temp = -100;
		if(rand()>$occupiedRatio){
			$temp = $noise + int(rand(4))-2;  # give a [-2,2] fluction to noise floor.
		}
		else{
			$temp = 0 - int(rand(80));
		}
		$sample[$i][$j]=$temp;
	}
	$sample[$i][$j++]=$occupiedRatio;
	#close fout;	
}

open fout, ">.\\randomDistance\\$fileName" or die "can not open file .\\randomDistance\\$fileName\n";
for($i=0;$i<$lengthOfSeries+1;$i++){
	for($j=0;$j<$numOfSeries;$j++){
		print fout "$sample[$j][$i] ";
	}
	print fout "\n";
}
close fout;
#print @sample;


